Resurrect vifname xm create vif option support. This was present in earlier
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 13 Dec 2005 18:06:03 +0000 (18:06 +0000)
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>
Tue, 13 Dec 2005 18:06:03 +0000 (18:06 +0000)
versions of Xen, and allows one to name a vif when it is created.  This is
useful for integration with IP accounting packages, for example.

Closes bug #439.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/examples/vif-common.sh
tools/python/xen/xend/server/netif.py

index 8c997f0d9990e93b23015ab9730bf68321971b20..3cbaa591b113bdee51352e5870ba6f35a913c367 100644 (file)
@@ -53,6 +53,17 @@ XENBUS_PATH="${XENBUS_PATH:?}"
 vif="${vif:?}"
 
 
+vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "")
+if [ "$vifname" ]
+then
+  if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null
+  then
+    do_or_die ip link set "$vif" name "$vifname"
+  fi
+  vif="$vifname"
+fi
+
+
 function frob_iptable()
 {
   if [ "$command" == "online" ]
index 9269d83ae002518cad8e158aa6c4a5b784acc5b7..1b073b3939d42425ebe92851d494b73b4900211d 100644 (file)
@@ -74,9 +74,10 @@ class NetifController(DevController):
         typ = sxp.child_value(config, 'type')
         if typ == 'ioemu':
             return (None,{},{})
-        bridge = sxp.child_value(config, 'bridge')
-        mac    = sxp.child_value(config, 'mac')
-        ipaddr = _get_config_ipaddr(config)
+        bridge  = sxp.child_value(config, 'bridge')
+        mac     = sxp.child_value(config, 'mac')
+        vifname = sxp.child_value(config, 'vifname')
+        ipaddr  = _get_config_ipaddr(config)
 
         devid = self.allocateDeviceID()
 
@@ -90,6 +91,8 @@ class NetifController(DevController):
             back['ip'] = ' '.join(ipaddr)
         if bridge:
             back['bridge'] = bridge
+        if vifname:
+            back['vifname'] = vifname
 
         front = { 'handle' : "%i" % devid,
                   'mac'    : mac }
@@ -102,9 +105,8 @@ class NetifController(DevController):
 
         result = DevController.configuration(self, devid)
 
-        (script, ip, bridge, mac) = self.readBackend(devid,
-                                                     'script', 'ip', 'bridge',
-                                                     'mac')
+        (script, ip, bridge, mac, typ, vifname) = self.readBackend(
+            devid, 'script', 'ip', 'bridge', 'mac', 'type', 'vifname')
 
         if script:
             result.append(['script',
@@ -116,5 +118,9 @@ class NetifController(DevController):
             result.append(['bridge', bridge])
         if mac:
             result.append(['mac', mac])
+        if typ:
+            result.append(['type', typ])
+        if vifname:
+            result.append(['vifname', vifname])
 
         return result